<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/common/common.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>用户注册</title>
<link href="<%=path %>/css/style.css" rel="stylesheet" type="text/css" />
<link href="<%=path %>/css/select.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="<%= basePath%>/third/jquery-validation-1.14.0/lib/jquery.js"></script>
<script type="text/javascript" src="<%= basePath%>/third/jquery-validation-1.14.0/dist/jquery.validate.js"></script>
<script type="text/javascript" src="<%= basePath%>/third/jquery-validation-1.14.0/dist/localization/messages_zh.js"></script>
<script type="text/javascript" src="<%=path %>/js/select-ui.min.js"></script>
<script type="text/javascript">
        $(function(){
		
			//如果是新增成功，会返回1，如果是1，则提示保存成功
			if("1" == "${actionState}"){
				alert('保存成功！');
			}
			//当没有添加角色时使用验证
			jQuery.validator.addMethod("checkRole", function(value, element) {   
			    if($("#roleId").attr("value")==undefined){
            		return false;
            	}else{
            		return true;
            	}
			}, ""),
			
            $("#commonform").validate({
                errorClass: "errorInfo", //默认为错误的样式类为：error
                focusInvalid: false, //当为false时，验证无效时，没有焦点响应  
                onkeyup: false,   
                submitHandler: function(form){   //表单提交句柄,为一回调函数，带一个参数：form   
					checkFrom();
                    form.submit();   //提交表单   
                },   
                rules:{
                    "userType":{
                        required:true,
                    },
                    "userPassword":{
                        required:true,
                        rangelength:[6,16]
                    },
                    "userphone":{
                        number:true,
                        rangelength:[10,11]
                    },               
                   
                   
                },
                messages:{
                    
                    "userType":{
                        required:"必填",
                    },       
                    "userPassword":{
                    	required: "必填",
                        rangelength: $.validator.format("最小长度:{0}, 最大长度:{1}。")
                    },
                    "userphone":{
                        number:"请输入正确的手机号!",
                        rangelength: $.validator.format("最小长度:{0}, 最大长度:{1}。")
                    }, 
                   
                    
                }  
            });   
        });
</script>



<script type="text/javascript">
	$(document).ready(function(e){
		$(".select2").uedSelect({
			width:155
		});
	});
</script>
</head>

<body>

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">新用户注册</a></li>
    </ul>
    </div>
    
    <div class="formbody"  id="tab1">
      
    <div class="formtitle"><span>基本信息</span></div>
    <form action="<%= basePath%>/front/Register_addRegisteractionUser.action" method="post" id="commonform">
    <ul class="forminfo">
     <li><label>身份类型</label>
				<input name="userType" id="userType" type="radio" value="0"  checked="checked"  />学生
				<input name="userType" id="userType" type="radio" value="1"   />教师
				<input name="userType" id="userType" type="radio" value="9"   />管理员
	<i><font color="#FF0000">*必选</font></i>
	</li>
	<li><label>用户编号</label><input name="sysUser.userId" type="text" placeholder="请输入用户编号" class="dfinput" /></li>
    <li><label>密码</label><input name="sysUser.userPassword" type="text" placeholder="请输入密码" class="dfinput" /></li>
    <li><label>姓名</label><input name="sysUser.userName" type="text" placeholder="请输入姓名" class="dfinput" /></li>
    <li><label>邮箱</label><input name="sysUser.userEmail" type="text" placeholder="请输入邮箱" class="dfinput" /></li>
    <li><label>身份证号</label><input name="sysUser.userStuID" type="text" placeholder="请输入正确的身份证号码" class="dfinput" /></li>
    <li><label>手机号码</label><input name="sysUser.userPhone" id="userTelephone" type="text" placeholder="请输入手机号码" class="dfinput"  /><i><font color="#FF0000"></font>11位大陆手机号</i></li>
      
    <li><label>性别</label>
				<input name="userSex" id="userSex" type="radio" value="1"  checked="checked"  />男
				<input name="userSex" id="userSex" type="radio" value="2"   />女
	</li>
    <li><label>学院</label><input name="sysUser.userCollege" type="text" placeholder="请输入学院名称" class="dfinput" ></input></li>
    <li><label>专业</label><input name="sysUser.userMajor" type="text" placeholder="请输入专业名称" class="dfinput" ></input></li>
    <li><label>科室</label><input name="sysUser.userStudio"type="text" placeholder="请输入科室名称" class="dfinput" ></input></li>
    <li><label>班级</label><input name="sysUser.userClass"type="text" placeholder="请输入班级名称" class="dfinput" ></input></li>
    <%-- 
    <li><label>驾校名称</label>
    <select id="schoolId" name="sysUser.schoolId"  required="required" class="dfinput">
    <option value="">请选择</option>
    <s:iterator value="sysUnitAllList" >
    <option value="${schoolId}" id="${schoolId}">${schoolName}</option>
    </s:iterator>
    </select>
    </li>
    --%>
    </ul>
    <ul class="forminfo">
    <li><label>&nbsp;</label><input name="" type="submit" class="btn" value="确认保存"/></li>
    </ul>
    </form>
    
    </div>

</body>


<script type="text/javascript">

    function find(){
        var strMerchantName = $("#merchant").val();             //获取搜索条件
        if(strMerchantName.trim() !="" || strMerchantName != null){                        
            $.ajax({
			   type: "POST",
			   url: "<%= basePath%>/biz/SysMerchantUnit_findByMerchantName.action",
			   data: {"strMerchantName":strMerchantName},
			   dataType: "json",				   
			   success: function(msg){    
	              var content = "<select id='tour_items' onclick=\"selectItem()\">";              //根据返回的json来生成景点列表下拉框
	              for(var i=0; i< msg.length; i++){
	                    content  = content + "<option value='"+msg[i].merchantId+"'>"+msg[i].merchantName+"</option>";
	              }
	              content  = content + "</select>"; 
	              $("#items").html(content);
	              itemsLength(msg.length);                          //根据json数组的长度来定义下拉框的长度
		     }
           });
       }
    }
    function itemsLength(len){                                  //根据json数组的长度来定义下拉框的长度
	    if(len <=5 && len > 1){
	         $("#tour_items").attr("size", len);
	    }else if(len == 1){
	         $("#tour_items").attr("size", 2);
	    }else if(len == 0){
	        $("#items").html("");
	        $("#merchant").val("-----该商家不存在-----");
	        setTimeout(function(){ $(' #merchant').val(''); }, 2000);
	    }else{
	        $("#tour_items").attr("size",5);
	   }   
   }
   function selectItem(){                           //当选择景点后赋值到文本框，并清除下拉框
        var strMerchantName= $("#tour_items").find("option:selected").text();                                   //获取被选中的option的文本
        var merchantId = $("#tour_items").find("option:selected").val();                                           //获取被选中的option的值
        $(" #merchant").val(strMerchantName);
        $(" #merchantId").val(merchantId);
        $("#items").html("");
   } 
   
   function hideItems(){                        //当鼠标离开文本框时触发该函数清除下拉框
       $("#items").html("");                                        
   }
</script>
</html>
